package zut.cs.liziflower.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import zut.cs.liziflower.entity.Orderitems;
import zut.cs.liziflower.mapper.OrderitemsMapper;
import zut.cs.liziflower.service.IOrderitemsService;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author xuwenke
 * @since 2022-05-26
 */
@Service
public class OrderitemsServiceImpl extends ServiceImpl<OrderitemsMapper, Orderitems> implements IOrderitemsService {

    @Resource
    private OrderitemsMapper orderitemsMapper;

    @Override
    public int addItem(Integer orderid, Integer userid, Integer flowerid, Integer num) {
        return orderitemsMapper.addItem(orderid, userid, flowerid, num);

    }

    @Override
    public List<Orderitems> getAllItems(Integer orderid, Integer userid) {
        return orderitemsMapper.getAllItems(orderid, userid);
    }

    @Override
    public int deletePaid(Integer orderid, Integer userid) {
        QueryWrapper<Orderitems> wrapper = new QueryWrapper<>();
        wrapper.eq("orderid", orderid).and(q -> q.eq("userid", userid));
        return orderitemsMapper.delete(wrapper);
    }


}
